<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			#text{
				width: 1000px;
				height: 40px;
			}
			a{
				display: block;
				text-align: center;
			}
			#div{
				display: none;
				position: fixed;
				top: 200px;
				left: 200px;
				width: 600px;
				border: 1px solid black;
				min-height: 300px;
				background: wheat;
			}
			#wzw{
				background: wheat;
			}
		</style>
	</head>
	<script charset="utf-8" src="/static/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
	<body>
		<div id="wz">
			<div id="div"></div>
			<div id="wzw">
				
			</div>
			<select id="select">
					    	<option value="1">1</option>
				</select>
			<div id="">
				<input type="text" id="text" value=""  placeholder="请输入标题"/>
			</div>
			<div id="">
				<textarea id="editor_id" name="content" style="width:700px;height:300px;">
			&lt;strong&gt;请输入内容&lt;/strong&gt;
			</textarea>
			</div>
		</div>
		<input type="button" id="btn" name="btn" value="发布" />
		<input type="button" id="ttt" value="预览" />
		    <script src="/bck/static/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		    <script type="text/javascript">
		        	var arr=[
        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
        'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
        'anchor', 'link', 'unlink', '|', 'about'
];
			KindEditor.ready(function(K) {
                var editor = K.create('#editor_id',{
                	width:'1000px',//设置编辑器的宽
                	//items:['undo', 'redo']	只出现两个undo	后退redo	前进按钮
                	items:arr,	//设置工具栏的按钮
                	uploadJson : '/ajax.php?ajax=upload',	//文件上传程序
					fileManagerJson : '/ajax.php?ajax=file_manager',	//浏览服务器图片空间
					allowFileManager : true,//启用图片空间按钮
                });
					
					
					
					$.ajax({
			            type:"get",
			            url:"/wenzhang1.php",
			            data:{
			                page:1
			            },
			            dataType:'json',
			            success:function(mgs){
			            	console.log(mgs);
			                var data=mgs.data;
			                var count=mgs.count;
			                var html='';
			                for (var i in data) {
			                    for (var d in data[i]) {
			                        if(d=='uid'||d=='name_id'||d=='time'||d=='img'||d=='recommend'||d=='name_id'||d=='content')
			                        {
			                            continue;
			                        }
			                        html+="<a uid="+data[i]['uid']+">"+data[i][d]+"</a>"
			                    }
			                    
			                }
			                $('#wzw').html(html);
			                var s='';
			                for (var i=1;i<=count;i++){
			                	s+="<option value='"+i+"'>"+i+"</option>";
			                }
			                $('#select').html(s);
			                $('#select').after("页"+" 共"+count+"页");
			                
			                $('a').click(function(){
			                	$.ajax({
				                    type:"post",
				                    url:"/wenzhang2.php",
				                    data:{
				                        uid:$(this).attr("uid")
				                    },
				                    dataType:'json',//dataType值如果为'json'，jquery就会把后端返回的字符串尝试通过JSON.parse()尝试解析为js对象。
				                    success:function(mgs){
				                        console.log(mgs);
				                        $('#div').html(mgs[0].content);
				                    }
				                });
			                	$('#div').show();
			                });
			            }    
					});
					
		            $('#btn').click(function(){
		            	//console.log(editor.html());
		                $.ajax({
		                    type:"post",
		                    url:"/wenzhang.php",
		                    data:{
		                        title:$('#text').val(),
		                        content:editor.html(),
		                    },
		                    //dataType:'json',dataType值如果为'json'，jquery就会把后端返回的字符串尝试通过JSON.parse()尝试解析为js对象。
		                    success:function(mgs){
		                        console.log(mgs);
		                    }
		                });
		            });
		        });
		    </script>
			
	</body>
</html>
